 # -*- coding:utf-8 -*-
import os
import re
import requests
import time

url = "http://data.zhugefang.com/Brokers/Api/Broker/insertBroker"
source = {'153':'百居易','147':'豪世华邦','150':'大唐房屋','3':'21世纪','2':'中原地产','4':'我爱我家','5':'Q房网','14':'房多多','9':'房天下','1':'链家','145':'中山房产','146':'大众房产','148':'创联房产','149':'国大地产','104':'到家了网','123':'中环地产'}
with open('cd/cd_20170818/broker_check/broker_check_test', 'r') as f:
    data = {}
    for i,line in enumerate(f.readlines()):
        line = line.strip('\n')
        lines =  line.split()
        if lines[1] not in source:
            data["city"] = "cd"
            data['list[0][name]'] = lines[1]
            data['list[0][phone]'] = lines[0]
            data['list[0][company]'] = source[lines[2]]
            data['list[0][source]'] = lines[2]
            print data
            req = requests.post(url,data)
            print req.text
            time.sleep(0.05)
